<template>
  <section id="noticeDetail">
    <div class="info_title">
      <router-link to="/announcement">平台公告</router-link>&nbsp;&gt;&nbsp;公告详情
    </div>
    <div class="content clearfix">
      <div class="list pull_left">
        <template v-if="dataList">
          <a
            class="item"
            href="javascript:void(0)"
            @click="curIndex=index"
            v-for="(item,index) in dataList.data"
            :key="index"
            v-if="index<7"
            :class="curIndex==index?'curr':''"
          >{{item.title}}</a>
        </template>

        <!-- <a href="/announcement" class="more">更多&gt;</a> -->
      </div>
      <div class="detail pull_right" v-if="dataList">
        <template v-if="dataList">
          <div class="title">{{ dataList.data[curIndex].title}}</div>
          <div class="time">{{ $js.timeToDate(dataList.data[curIndex].create_time) }}</div>
          <div class="content_detail" v-html="dataList.data[curIndex].content"></div>
        </template>
      </div>
    </div>
  </section>
</template>
<script>
import { _getPNoticeList } from "@/axios/index.js";

export default {
  data() {
    return {
      newsList: [
        {
          id: 1,
          name: "01月10日系统升级公告"
        },
        {
          id: 2,
          name: "关于V网OTC大区开放稳定币KHT交易的公告"
        },
        {
          id: 3,
          name: "01月10日系统升级公告"
        },
        {
          id: 4,
          name: "01月10日系统升级公告"
        },
        {
          id: 5,
          name: "01月10日系统升级公告"
        }
      ],
      params: {
        page: 1,
        pagesize: 14
      },
      dataList: "",
      curIndex: 0
    };
  },
  methods: {
    
    async getMethod() {
      var self = this;
      let res = await _getPNoticeList(self.params.page, self.params.pagesize);
      if (res.data.code == 200) {
        var id = self.$route.params.id;
        var item = localStorage.getItem("curNotice")
          ? JSON.parse(localStorage.getItem("curNotice"))
          : "";
        self.dataList = res.data.data;
        if (item && item.id == id && self.dataList.total) {
          for (var i = 0; i < self.dataList.data.length; i++) {
            var iItem = self.dataList.data[i];
            if (iItem.id == id) {
              self.dataList.data.splice(i, 1);
            }
          }
          self.dataList.data.unshift(item);
        }
       
      }
    }
  },
  created() {
   
    this.getMethod();
  },
  destroyed() {
   
  }
};
</script>
